package db.user;

import org.hibernate.Query;
import org.hibernate.classic.Session;

import db.AbstractService;

public class UserService extends AbstractService<User> implements UserDAO
{
    public void registerUser(String name, String password, String email, Boolean admin) {
        User user = new User();
        user.setName(name);
        user.setPassword(password);
        user.setEmail(email);
        user.setAdmin(admin);
        insert(user);
    }
    
    public User findByName(String name) {
        Session session = sessionFactory.getCurrentSession();
        try {
            Query query = session.createQuery("from User where name = '" + name + "'");
            return (User)query.uniqueResult();
        } finally {
            //session.close();
        }
    }
}
